Thank you for the links.
#define SPINDLEAXIS 5 // Axis Channel to Jog to rotate Spindle
#define FACTOR (1000/60.0) // to convert RPM to counts/sec (counts/rev / 60.0sec)
#define SPINDLECW_BIT 1024 // bit to activate to cause CW rotation
#define SPINDLECCW_BIT 1025 // bit to activate to cause CCW rotation
#define SPEEDVAR 99 // global persistant variable to store latest speed
#define STATEVAR 98 // global persistant variable to store latest state (-1=CCW,0=off,1=CW)
#define KMVAR PC_COMM_CSS_S 113 // variable KMotionCNC will pass speed parameter (113)
#define USE_POS_NEG_VOLTAGE 1 // 0 = output Magnitude, 1 = output positive and negative speed
So it works now.YEAH!! Thanks Tom. The root cause was changing the bits to 1024 & 1025. Along with my #define KMVAR PC_COMM_CSS_S 113 had no 113 in it. I went back to all original settings to review the MySpindleDefs.h file and it had no number here. Your previous advice and documents/notes told me there was supposed to be a 113 here. I tried all of these settings previously, but must have missed something.
This is all great stuff with starting to see it come alive.
1)One thing I have noticed is that It requires 2 presses of m3, m4 & m5 userbutton for it to acknowledge the respective command. 1 press of each userbutton will not trigger the function. Is this normal? (Not a big deal to me at this point as a single M3 command via gcode will activate it and this is where it counts)
2)Another Kmotion error I am seeing is that when I single step through a line of gcode such as "s1000m3", It gives me the following error:
Error compiling and loading kmotion Program
C:\kmotion 433c\....\css\spindlejog.c:13;"]"expected.
I believe The line where this issue is starts with. " Float speed=...." I do not see where to insert a ]
...?
below is my Spindlejoge.c file:
#include "KMotionDef.h"
#include "MySpindleDefs.h"
int *css_mode = &persist.UserData[PC_COMM_CSS_MODE]; // Mode 1=Normal RPM mode. 2=CSS
// desired speed is passed from KMotionCNC in variable KMVAR
// save in user variable STATEVAR whether it was off, CW, or CCW (0,1,-1)
// save in user variable SPEEDVAR the last desired speed
main()
{
float speed = *(float *)&persist.UserData[KMVAR]; // value stored is actually a float
float LastState = persist.UserData[STATEVAR]; // get last state
persist.UserData[SPEEDVAR] = persist.UserData[KMVAR]; // Always save the last desired speed
if (LastState==0 || *css_mode == 2)
{
// if spindle is off (or CSS mode) and User Changes the speed
// just save the desired speed
return 0;
}
// spindle is already on, so ramp to new speed
if (USE_POS_NEG_VOLTAGE)
Jog(SPINDLEAXIS,speed * FACTOR * LastState);
else
Jog(SPINDLEAXIS,speed * FACTOR);
printf("Jogging Spindle %f counts/sec\n",speed * FACTOR);
}
Is there a way to get rid of this error?
.........
Thanks so much Tom.
Have a great weekend!
Rob